#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Maipu::ShowVersion < Aio::Module::Cmd::Maipu
  include Aio::Module

  def initialize
    super({
      :cmd_full		=> "show version",
      :cmd_short	=> "sh ver",
      :author			=> "Elin",
      :description	=> "This is Maipu Command# show version",
      :ranking		=> Ranking_1,
      :platform		=> "all",
      :key_stand 	=> true,
      :benchmark	=> {}
    })
  end

  def parse
    cont = self.context.dup
    soft_info = {}
    useful[:software] = soft_info

    cont.readline_match_block(/MyPower \(R\) Operating System Software/) do |block|
      key_stand_maipu
    end
    cont.readline_match_block(/(?<device_model>.*) Version Information/) do |block|
      block.update(soft_info, :device_model)
    end
    cont.readline_match_block(/System ID : (?<board_id>.*)/) do |block|
      block.update(soft_info, :board_id)
    end
    cont.readline_match_block(/Hardware Model : (?<hw_info>.*)/) do |block|
      block.update(soft_info, :hw_info)
    end
    cont.readline_match_block(/Software Version : (?<version>.*)/) do |block|
      block.update(soft_info, :version)
    end
    cont.readline_match_block(/Software Image File : (?<soft_image>.*)/) do |block|
      block.update(soft_info, :soft_image)
    end
    cont.readline_match_block(/System Uptime is (?<uptime>.*)/) do |block|
      block.update(soft_info, :uptime)
    end
  end

end

